package com.learning.netease.optimize.jdk.thread.pool;

import java.util.concurrent.CountDownLatch;

/**
 * ClassName: MaxThreadDemo
 * Description: 线程是不是越多越好?
 * Date: 2019/2/3 9:37 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
public class MaxThreadDemo {

    public static void main(String[] args) throws InterruptedException {
        CountDownLatch downLatch = new CountDownLatch(1);

        Thread.sleep(20000L);

        for (int i = 0; i < 5000; i++) {

            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        // 线程全部在这边阻塞
                        downLatch.await();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }).start();


            System.out.println("i = " + i);
        }
    }
}
